# @Time : 2024-09-27 15:28
# @Author : Fioman
# @Phone : 13149920693
"""
项目全局配置,声明为模块级变量,包括项目名称,项目的数据库名称,项目中的文件目录等.
"""
import os
import queue
import sys

project_name = "xinfjingwang_01"
database_name = f"params_{project_name}"
is_main_alive = False
is_develop = True if len(sys.argv) >= 2 else False
base_dir = os.path.dirname(os.path.abspath(__file__))
web_path = os.path.join(base_dir, "web")
zmc_lib_path = os.path.join(base_dir, r'dll\zmotion.dll')
aux_zmc_lib_path = os.path.join(base_dir, r'dll\zauxdll.dll')
camera_lib_path = os.path.join(base_dir, r"dll\MvCameraControl.dll")
debug_dir = os.path.join(base_dir, "debug")
# 一些工具中的使用的图片保存目录,保存到D盘中的raw_tool中
calibration_dir = r"D:\raw_tool\raw_calibartion"  # 上料相机标定目录
image_joint_dir = r"D:\raw_tool\raw_joint"  # 上料相机拼接目录
count_board_size_dir = r"D:\raw_tool\raw_joint\count_board_size"  # 统计8张图的图片保存目录
cutter_cam_cal_dir = r"D:\cutter_raw\raw_calc"  # 铡刀标定目录
database_dum_dir = os.path.join(base_dir, r"db_data\data_dump")  # 数据库备份目录
database_import_dir = os.path.join(base_dir, r"db_data\data_import")  # 数据库导入目录


# 上面的这些目录不存在要手动创建
def tool_dir_init():
    dir_list = [calibration_dir, image_joint_dir, count_board_size_dir, cutter_cam_cal_dir,
                database_dum_dir, database_import_dir, debug_dir]
    for dir_path in dir_list:
        try:
            if not os.path.exists(dir_path):
                os.makedirs(dir_path)
        except Exception as e:
            print(f"in tool_dir_init() error: {str(e)}")


# 固定目录初始化
tool_dir_init()

# 一些全局变量,比如webSocketQueue和前端通信的一些全局变量
websocket_q = queue.Queue()

# 图像的一些目录,在自动作业开始之前,根据order_id去创建,包括横拼,横拼的后面加一个hp,然后正常的是sp
first_cut_board_dir_2pin = None
size_check_ok_dir_2pin = None
raw_ok_dir_2pin = None
raw_cut_dir_2pin = None
totalboard_error_dir_2pin = None
raw_fail_dir_2pin = None

first_cut_board_dir_1pin = None
size_check_ok_dir_1pin = None
raw_ok_dir_1pin = None
raw_cut_dir_1pin = None
totalboard_error_dir_1pin = None
raw_fail_dir_1pin = None
# 铡刀目录
cutter_raw_begin_dir = None
cutter_raw_begin_res_dir = None
cutter_raw_final_dir = None
cutter_raw_final_res_dir = None
